﻿function DisplayErrorReportForm()
{
    var htm = '';
    htm+= '<table cellspacing=0 bgcolor="#c9d7f1" width="100%" style="border-bottom:solid 1px #999">';
    htm+= '<tr><td valign=top style="padding:10px 0px 10px 10px">';
    htm+=' <a onclick="SettingsPageEvent.invoke()" href="javascript:void(0)">&#171; Back to Settings</a>';
    htm+= '<iframe id=igoogle name=igoogle ';
    htm+= ' src="http://spreadsheets.google.com/embeddedform?key=p46wWp5LXrx1q2NHFxhYsNQ" ';
    htm+= 'width="310" height="698" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>';;
    htm+= '</td></tr></table>'; 
    return htm;
}

function OnDisplayErrorReport()
{
    AttachResizer ('igoogle', 20, 100);
}

function DisplayErrorReportList()
{
    var row=0,htm = '';
    var odd,nm,mm,re = [];
    re['page']=/page\:\s+(.*),\s+description/ 
    re['desc']=/description\:\s+(.*),\s+intensity/ 
    re['in10']=/intensity\:\s+(.*),\s+status/ 
    re['stat']=/status\:\s+(.*)/ 
    htm+= '<table cellspacing=0 bgcolor="#c9d7f1" width="100%" style="border-bottom:solid 1px #999">';
    htm+= '<tr><td valign=top style="padding:10px 0px 10px 10px">';
    htm+=' <a onclick="SettingsPageEvent.invoke()" href="javascript:void(0)">&#171; Back to Settings</a>';
    htm+= '<div id=igoogle name=igoogle style="overflow:auto;padding:4px;border:solid 1px #666;background-color:white">';  
    htm+= '<blockquote>';  
    htm+= '<h2>' + APPLICATION_NAME + ' Known Issues</h2>';  
    htm+= 'We\'re always working to resolve problems that come up in ' + APPLICATION_NAME + '. ';  
    htm+= 'If your problem is listed below, we\'re aware of the issue and are working to fix it as soon as possible. ';  
    htm+= 'To see more information on an issue, just click "View Details & Report." ';  
    htm+= 'Clicking the "Report it" button will save you the time of sending us an email, ';  
    htm+= 'but will ensure that we\'re notified about your issue.</blockquote> ';
    var tmp,d3=[];
    for (var x in window.rss)
    {  
        if (window.rss[x].length > 0)
        {
            tmp=[];
            for (var i in re)
            {
                mm = re[i].exec (window.rss[x]);
                tmp[i] = (mm?mm[1]:'');
            }
            
            if (tmp['desc'].length>0)
			{
				if (! d3[tmp['page']] ) d3[tmp['page']] = [];
                d3[tmp['page']].push (tmp); 
			}
        }
    } 
    
    
    for (var x in d3)
    { 
        htm +='<table cellpadding="4" cellspacing="1" width="65%" align=center><tr>';
        htm += '<td colspan="2"><br><br><b>' + x + '</b></td>';
        htm +='</tr>'; 
        odd = false;
        for (var i in d3[x])
        { 
            nm = d3[x][i]['desc'];
			
			hue = {
			    even : d3[x][i]['stat']=='COMPLETE'?'#efefff':'#ffefef',
				odd : d3[x][i]['stat']=='COMPLETE'?'#D0E0FF':'#FFD0E0' 
			}
			
			if (nm.length>0)
			{
				htm +='<tr bgcolor="'+(odd?hue.odd:hue.even)+'">';
				htm += '<td nowrap style=color#666>&nbsp;&nbsp;' + nm.substr (0,60) + (nm.length>60?'...':'') + '</td>';
				htm += '<td align="center" nowrap><a href="javascript:void(0)" onclick=\'toggle_tr ("et-' + row + '");\'>View Details & Report</a></td>';
				htm +='</tr>';
				htm +='<tr bgcolor="#ffffff" style="display:none" id="et-' + row + '">';
				htm += '<td><div id="tx-' + row + '" style="width:65%">' +nm + '</div><br><br><font color=#666>';
				htm += 'Level: '+d3[x][i]['in10']+', ';
				htm += 'Status: '+d3[x][i]['stat']+'';
				htm += '';
				htm += '</font></td>';
				htm += '<td align="center">';
				htm += '<input type="button" value="Report It!" onclick="DialogMail(' + row + ')"/>'; 
				htm += '</td>';
				htm +='</tr>';
				odd=!odd;
			}
            row++;
        } 
        htm+= '</table>'; 
    } 
    htm+= '<hr noshade size="1"/>'; 
    htm+= '</div>'; 
    htm+= '</td></tr></table>'; 
    return htm; 
}  

function DialogMail(row)
{
	var dx = document.getElementById ('tx-' + row);
	if (!dx) return false;
	Controller.message = dx.innerHTML;
	Controller.to = 'mjones@cyber8.net';
	Controller.subject = APPLICATION_NAME + ' - trouble report';
	WindowEmail.invoke ();
}
